package com.clayecloud.common.client.controller;

import com.clayecloud.common.annotation.NoAuthorization;
import com.clayecloud.common.client.entity.ClientRegister;
import com.clayecloud.common.client.services.UserServices;
import com.clayecloud.common.entity.User;
import com.clayecloud.common.utils.MessageUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author ClayeLink
 * @date 2022/3/13 16:48
 */
@RestController
@RequestMapping("/register")
@Api(tags = "注册接口")
public class ClientRegisterController {

    @Resource
    private UserServices userServices;

    /**
     * 获取用户信息
     * @return
     */
    @PostMapping("/insert")
    @ApiOperation("注册账户")
    @NoAuthorization
    public MessageUtil createUser(@RequestBody ClientRegister register){
        // 接入验证码系统，处理验证码校验
        User user = new User();
        user.setUserPhone(register.getUserPhone());
        user.setUserMail(register.getStr_email());
        user.setUserName(register.getStr_username());
        user.setUserPassword(register.getStr_loginPassword());
        user.setUserState(0);
        user.setUserAvatar("https://portrait.gitee.com/uploads/avatars/user/2534/7604138_clayelink_1619077375.png!avatar200");
        return userServices.insertSelective(user);
    }


}
